/**
 * Copyright (C) 2010-2011 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.seequencer.client;

import org.seequencer.client.common.AudioElement;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.ToggleButton;
import com.google.gwt.user.client.ui.VerticalPanel;

@Deprecated
public class Seequencer implements EntryPoint {

	int initialBpm = 100;

	boolean[] line1 = new boolean[16];

	boolean[] line2 = new boolean[16];

	final Label[] labelsToIndicatePlay = new Label[16];

	// <audio src="data:audio/wav;base64,[base64 encoded data]"></audio>
	String kickDataSrc = "data:audio/wav;base64,UklGRhwMAABXQVZFZm10IBAAAAABAAEAgD4AAIA+AAABAAgAZGF0Ya4LAACAgICAgICAgICAgICAgICAgICAgICAgICAf3hxeH+AfXZ1eHx6dnR5fYGFgoOKi42aloubq6GOjI2Op7ythXJ0eYF5aV1AOFFib32HmZSHhpCalIiYi4SRkZaLfnhxaWptb21qaWBea2BRYmZTVmFgWFNXVVVhaGdbYGhZbXh1gXZ1goeIlot1k6yxtKaOkaWhq7KonKCZoaCjoKWuqqmurK6ztrO7tbTAvru/vb68vbW6vLGqsLOfm5yal5KKhoyBeHt2dXBnbmljVlJWUEBBPDw9Mi4zKRwhIBYaGRQcHBURGB0XFx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AgICBgICAgYCBgIGAgYCBgIGAgYCBgICAgICAgICAgICAgICAgICBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYCBgIGAgYGAgIGAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIGAgYCBgIGAgYCBgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGBgIGAgYCBgIGAgYCBgIGAgICAgICAgICAgICAgICAgICAgICAgICAgIGAgYCBgIGAgYCAgYCAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIGAgYCBgICAgICAgICAgICAgICAgICAgICBgIGAgYCAgYCBgIGAgICAgICAgICAgICAgICAgICAgICAgABMSVNUQgAAAElORk9JQ1JEDAAAADIwMDgtMDktMjEAAElFTkcDAAAAIAAAAUlTRlQWAAAAU29ueSBTb3VuZCBGb3JnZSA4LjAAAA==";

	AudioElement audioElementKick = new AudioElement(kickDataSrc);
	AudioElement audioElementSnare = new AudioElement(snareDataSrc);

	int stepCounter = 0;

	public void onModuleLoad() {

		for (int i = 0; i < labelsToIndicatePlay.length; i++) {
			labelsToIndicatePlay[i] = new Label();

		}

		// Create a grid

		// first colum is the name
		Grid grid = new Grid(3, 17);

		// Add images to the grid
		final int numRows = grid.getRowCount();
		final int numColumns = grid.getColumnCount();

		for (int row = 0; row < numRows; row++) {
			for (int col = 0; col < numColumns; col++) {

				// inits:
				if (col == 16) {
					if (row == 0) {
						grid.setWidget(row, col, new Label("Beat"));

					} else if (row == 1) {

						grid.setWidget(row, col, new Label("Snare"));

					}

					continue;

				}

				if (row == 2) {

					if (col < 16) {
						grid.setWidget(row, col, labelsToIndicatePlay[col]);
					}
					continue;

				}

				final int colo = col;
				final int rowo = row;

				ToggleButton button = new ToggleButton("#" + colo);
				button.addClickHandler(new ClickHandler() {

					@Override
					public void onClick(ClickEvent event) {

						if (rowo == 0) {

							line1[colo] = !line1[colo];

						} else if (rowo == 1) {
							line2[colo] = !line2[colo];
						}

					}
				});

				grid.setWidget(row, col, button);

			}
		}

		for (boolean bool : line1) {
			bool = false;
		}

		for (boolean bool : line2) {
			bool = false;
		}

		final Timer masterTimer = new Timer() {

			@Override
			public void run() {

				for (Label label : labelsToIndicatePlay) {

					label.setText("");
				}

				labelsToIndicatePlay[stepCounter].setText("*");

				// RootPanel.get().add(new Label("playing: " + stepCounter));
				if (line1[stepCounter]) {
					audioElementKick.play();

				}

				if (line2[stepCounter]) {
					audioElementSnare.play();

				}

				// reset stepcounter
				if (stepCounter >= 15) {
					stepCounter = 0;

				} else {
					stepCounter++;
				}

			}

		};

		masterTimer.scheduleRepeating(fromBpmToMs(initialBpm));

		// 2 spuren => 16 toggle buttons
		// layout: toogle buttons

		VerticalPanel vp = new VerticalPanel();
		Anchor header = new Anchor(
				"Seequencer - the pure HTML 5 sequencer using audio elements - Contribute - it's open source :)");
		header.setHref("http://gwt-seequencer.googlecode.com");
		vp.add(header);

		vp.add(grid);

		final TextBox bpmBox = new TextBox();
		bpmBox.setText("" + initialBpm);

		final ToggleButton playStop = new ToggleButton("play/stop");
		playStop.setDown(true);
		playStop.addClickHandler(new ClickHandler() {

			@Override
			public void onClick(ClickEvent event) {
				if (!playStop.isDown()) {

					masterTimer.cancel();
				} else {
					// start timer...

					try {
						int thisBpm = Integer.parseInt(bpmBox.getText());

						Window.alert("setting to: " + fromBpmToMs(thisBpm));
						masterTimer.scheduleRepeating(fromBpmToMs(thisBpm));

					} catch (NumberFormatException e) {

						Window.alert("Hey! please enter valid bpm in textarea :) thanks!");
						e.printStackTrace();
					}

				}
			}
		});

		vp.add(playStop);

		vp.add(bpmBox);

		RootLayoutPanel.get().add(vp);

	}

	// bpm = 60000 / 4 / 300
	/**
	 * we are in 4/4 mode 16 steps... 60000ms = 1 min;
	 * 
	 * bpm = 60000 / 4 / ms
	 * 
	 * ms = 15000 / bpm
	 * 
	 * 
	 * 
	 * 
	 */
	public int fromBpmToMs(int bpm) {

		return 15000 / bpm;

	}

}
